package com.sanchunhui.psc.service.impl

import com.sanchunhui.psc.data.protocol.ResponseInfo
import com.sanchunhui.psc.data.protocol.UserInfo
import com.sanchunhui.psc.data.respository.ProjectTeamRepository
import com.sanchunhui.psc.ext.convert
import com.sanchunhui.psc.ext.convertBoolean
import com.sanchunhui.psc.service.ProjectTeamService
import rx.Observable
import javax.inject.Inject

/**
 * @Author zyx
 * @Date 2021/7/8-14:42
 * @Dscribe 分组管理业实现类
 */
class ProjectTeamServiceImpl @Inject constructor(): ProjectTeamService {

    @Inject
    lateinit var repository : ProjectTeamRepository

    /*
        获取分组列表
     */
    override fun getTeamList(token: String): Observable<ResponseInfo> {
        return  repository.getTeamList(token)
    }

    /*
         获取分组下所有成员
     */
    override fun getTeamMember(teamID: Int, token: String): Observable<ResponseInfo> {
        return repository.getTeamMember(teamID, token)
    }

    /*
        添加分组到所在项⽬
     */
    override fun addTeam(
        token: String,
        name: String,
        leader_member_id: Int
    ): Observable<ResponseInfo> {
        return repository.addTeam(token,name,leader_member_id)
    }

    /*
        获取所有未在项⽬中⽤户的列表
     */
    override fun getSearchMember(
        token: String,
        name: String?, company_id:Int?, job_id:Int?
    ): Observable<MutableList<UserInfo>?> {
        return repository.searchMember(token,name,company_id,job_id).convert()
    }

    /*
        获取所有公司组成的映射（键值对）
     */
    override fun getCompanyList(token: String): Observable<ResponseInfo> {
        return repository.getCompanyList(token)
    }

    /*
          获取所有⼯种组成的映射（键值对）
     */
    override fun getJobList(token: String): Observable<ResponseInfo> {
        return repository.getJobList(token)
    }

    /*
        更改分组状态
    */
    override fun changeTeamStatus(teamId: Int,token: String, status:String): Observable<Boolean> {
        return repository.changeTeamStatus(teamId,token, status).convertBoolean()
    }

    /*
        添加小组成员
     */
    override fun addTeamMember(teamId: Int, token: String, ads: List<Int>): Observable<Boolean> {
        return repository.addTeamMember(teamId,token,ads).convertBoolean()
    }

    /*
      设置指定分组名称
     */
    override fun setTeamInfo(teamId: Int, token: String, name: String): Observable<Boolean> {
        return repository.setTeamInfo(teamId,token, name).convertBoolean()
    }

    /*
        设置指定分组负责⼈
     */
    override fun setTeamLeader(teamId: Int, token: String, id: Int): Observable<Boolean> {
        return repository.setTeamLeader(teamId,token,id).convertBoolean()
    }

    /*
        移除项⽬（分组）中的成员
     */
    override fun deleteMember(token: String, id: Int): Observable<Boolean> {
        return repository.deleteMember(token,id).convertBoolean()
    }

    /*
        获取分组在线的成员ID
     */
    override fun getOnlineMember(teamId: Int, token: String): Observable<MutableList<Char>> {
        return repository.getOnlineMember(teamId,token).convert()
    }

    override fun getTeamInfo(token: String): Observable<ResponseInfo> {
        return repository.getTeamInfo(token)
    }

    override fun getProjectTeamInfo(teamId: Int, token: String): Observable<ResponseInfo> {
        return repository.getProjectTeamInfo(teamId,token)
    }

    /*
        获取所在项⽬信息
     */
    override fun getProjectInfo(token: String): Observable<ResponseInfo> {
        return repository.getProjectInfo(token)
    }

    /*
        更改项⽬状态
     */
    override fun changeProjectStatus(token: String, status: String): Observable<ResponseInfo> {
        return repository.changeProjectStatus(token,status)
    }
}